<?php
namespace app\api\controller\robat;

use app\api\controller\Base;
use app\common\model\company\Contract as Contractmodel;
use think\Controller;


class Contract extends Base
{
    /**
     * 完善合同密码
     * @return [type] [description]
     */
    public function perfect()
    {
        $data = Contractmodel::whereNull('PrintPassword')->limit(100)->select();
        // dump($data);
        // exit;
        if (empty($data)||count($data)==0) {
            return moerr('没有需要操作的数据');
        } else {
            foreach ($data as $key => $value) {
                $value->PrintPassword = md5(time() . rand(0, 100) . 'contract' . $value['CompanyId'] . time() . $value['BussinessId'] . time() . $value['ContractCost'] . rand(0, 100));
                $value->save();
            }
            echo "<script>location.reload();</script>";
            echo '正在操作中...';
            return;
            // return myok('执行成功');
        }
    }

    

}
